package com.example.libreoffice_study.controller;

import com.example.libreoffice_study.util.FileConvertUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;

@RestController
public class TestController {

    @RequestMapping("/test")
    public void test(@RequestParam("file") String file, @RequestParam("type") String type) throws Exception {
        byte[] docs = FileConvertUtil.convertLocaleFile(file, type);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(docs);
        FileOutputStream out = new FileOutputStream("D://test.pdf");
        outputStream.writeTo(out);
        outputStream.close();
        out.close();
        System.out.println("装换完成");
    }

}
